﻿using System.Collections.Generic;
using System.Data;

namespace MsgQueueTest.Data
{
    public class TemplateManager
    {
        private static Dictionary<string,DataTable> templateDictionary=new Dictionary<string, DataTable>();

        public Dictionary<string, DataTable> TemplateDictionary
        {
            get { return templateDictionary; }
            set { templateDictionary = value; }
        }

        public DataTable GetTemplate(string templateName)
        {
            if(!templateDictionary.ContainsKey(templateName.ToLower()))
            {
                var command = string.Format(
                "SELECT * FROM DeliveryManager.dbo.Notify_Template WHERE TemplateName='{0}'", templateName);

                var dataTable = DataManager.ExecStringCommandDataSet(command);

                templateDictionary.Add(templateName.ToLower(), dataTable);
            }

            return templateDictionary[templateName.ToLower()];
        }
    }
}
